package com.example.myapplication.apter;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.myapplication.R;
import com.example.myapplication.ShuJu.Re_Servlet;
import com.example.myapplication.ShuJu.ReviewBean;
import com.example.myapplication.library.LibraryMainActivity;

import java.util.List;

public class EventDetailsAdapter  extends  RecyclerView.Adapter<EventDetailsAdapter.MyServer>{
    private Context context ;
    private List<ReviewBean.RowsBean> list;
    private View view;


    public EventDetailsAdapter(Context context, List<ReviewBean.RowsBean> list) {
        this.context = context;
        this.list = list;

    }

    @NonNull
    @Override
    public EventDetailsAdapter.MyServer onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        //填充试图
        view = LayoutInflater.from(context).inflate(R.layout.item_review,null);
        return new EventDetailsAdapter.MyServer(view);
    }

    @Override
    public void onBindViewHolder(@NonNull EventDetailsAdapter.MyServer holder, int position) {
        Glide.with(context).load("http://124.93.196.45:10001"+list.get(position).getAvatar()).into(holder.review_cover);
        holder.review_content.setText(list.get(position).getContent());
        holder.reviewName.setText(list.get(position).getNickName());
        holder.review_Date.setText(list.get(position).getCommentTime());
    }

    @Override
    public int getItemCount() {
        return list==null?0:list.size();
    }

    class  MyServer extends RecyclerView.ViewHolder{


        private final TextView reviewName;
        private final TextView review_Date;
        private final TextView review_content;
        private final ImageView review_cover;

        public MyServer(@NonNull View itemView) {
            super(itemView);

            review_cover = itemView.findViewById(R.id.review_cover);
            reviewName = itemView.findViewById(R.id.reviewName);
            review_content = itemView.findViewById(R.id.review_content);
            review_Date = itemView.findViewById(R.id.review_Date);
        }
    }
}

